<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<?#include "headShare.html";#?>
	<title><?#=$lang['10000'];?></title>
    <script language="javascript">
        Ext.onReady(function() {
        	Ext.QuickTips.init();
            Ext.BLANK_IMAGE_URL = "/static/extjs/images/s.gif";
            var captcha  = "/admin/captcha.html";
            var logoPanel= new Ext.Panel({
                html     : '<img width="348" height="96" src="/static/extjs/images/login-banner.jpg"/>'
            });
            var loginForm= new Ext.form.FormPanel({
                    bodyStyle   : 'background:#dfe8f6; padding-top:8px;',
                    labelAlign  : 'right',
                    defaultType : 'textfield',
                    defaults	: {
                        allowBlank  : false
                    },
                    items       :   [{
                        fieldLabel  : '<?#=$lang['10002'];?>',
                        name        : 'account',
                        width       : 140,
                        regex       : /^[\w\.\@]{5,}$/,
                        regexText	: '<?#=$lang['10007'];?>',
                        blankText   : '<?#=$lang['10008'];?>'
                    },{
                        fieldLabel  : '<?#=$lang['10003'];?>',
                        name        : 'loginpw',
                        width       : 140,
                        inputType   : 'password',
                        regex       :  /^[^\s]{6,}$/,
                        regexText	: '<?#=$lang['10009'];?>',
                        blankText   : '<?#=$lang['10011'];?>'
                    },{
                        xtype       : 'vcodefield',
                        fieldLabel  : '<?#=$lang['10004'];?>',
                        name        : 'vcode',
                        vh          : 20,
                        vw          : 62,
                        vsrc        : captcha,
                        width       : 70,
                        regex       : /^[\w]{4,5}$/i,
                        regexText	: '<?#=$lang['10012'];?>',
                        blankText   : '<?#=$lang['10013'];?>'
                    }],
                     keys:[{
                        key         : Ext.EventObject.ENTER,
                        fn          : function() {
                        	if(!Ext.Msg.isVisible()) {
                        		doLogin();
           					}
                        },
                        scope       :   this
                    }]
                });
            var copyRight= new Ext.Panel({
                bodyStyle   : 'background:#dfe8f6;left:76px;position:absolute;bottom:12px;',
                html        : '&copy2012-'+(new Date()).getFullYear()+' <?#=$lang['10014'];?>'
            });
            
            var btnPanel = new Ext.Panel({
                buttonAlign : 'center',
                buttons     : [{text:'<?#=$lang['10005'];?>',width:66, handler:doLogin}, {text:'<?#=$lang['10006'];?>',width:66,handler:function(){
                    loginForm.form.reset();
                    loginForm.form.findField('account').focus();
                }}]
            });
            
            var loginWin = new Ext.Window({
                title     : '<?#=$lang['10001'];?>',
                modal     : false,
                resizable : false,
                draggable : false,
                closable  : false,
                defaults  : {
                    border : false
                },
                height    : 272,
                width     : 344,
                items     : [logoPanel, loginForm, btnPanel, copyRight]
            });
			loginWin.render(Ext.getBody());
			loginWin.show();
			window.onresize = function () {
				loginWin.center();
			}
			function doLogin() {
		        if(!loginForm.getForm().isValid())
		        	return;
		        loginForm.getForm().submit({
		        	waitMsg : '<?#=$lang['10015'];?>',
					waitTitle : '<?#=$lang['10016'];?>',
		        	clientValidation: true,
		        	url: '/admin/login/check.html',
		        	success: function(form, action) {
		        		window.location.href = action.result.msg;
					},
					failure: function(form, action) {
						var src = loginForm.getForm().findField('vcode').vsrc;
						var glun= (src.indexOf('?') > 1)? '&':'?';
						Ext.get('vs-verifycode').dom.src = src+glun+(new Date()).getTime();
				        switch (action.failureType) {
				            case Ext.form.Action.CLIENT_INVALID:
				                Ext.Msg.alert('<?#=$lang['10016'];?>', '<?#=$lang['10017'];?>');
				                break;
				            case Ext.form.Action.CONNECT_FAILURE:
				                Ext.Msg.alert('<?#=$lang['10016'];?>', '<?#=$lang['10018'];?>');
				                break;
				            case Ext.form.Action.SERVER_INVALID:
				               Ext.Msg.alert('<?#=$lang['10016'];?>', action.result.msg);
				       }
				    }
			    });
		    }
        });
    </script>
</head>
<body>
</body>
</html>